package com.example.day03;

import com.example.utils.DateUtil;

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class CalanderTest {
    public static void main(String[] args) {


        Scanner scanner=new Scanner(System.in);


        System.out.println("year_>:");
        int year=scanner.nextInt();

        System.out.println("month_>:");

        int month=scanner.nextInt();

        print(year,month);
    }

    private static void print(int year, int month) {

        System.out.printf("\t\t%d年%d月\n",year,month);
        System.out.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n","日","一","二","三","四","五","六");

        //1.获取当月的第一天是星期几
            int week= DateUtil.getDayOfWeek(year,month,1);
        //2.判断该月有几天
        int max=DateUtil.getMaxDays(year, month);

        //3.今天是几号
        int date=Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

        int count=0;

        for(int i=0;i<week;i++){
            System.out.print("\t");
            count++;
        }
        for(int i=1;i<=max;i++){
            System.out.print(i==date?(i+"*\t"):(i+"\t"));
            if(++count==7){
                System.out.println();
                count=0;
            }
        }




    }
}
